<%@ page import="net.ojbk.study.curriculumDesign.beans.usermanage.User" %><%--
  Created by IntelliJ IDEA.
  User: hongfive
  Date: 2019/1/9
  Time: 11:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basepath = request.getScheme()
            + "://" + request.getServerName()
            + ":" + request.getServerPort() + "/" + path;
    User user= (User) session.getAttribute("user");
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="<%=basepath%>/statics/style/css/index.css">
    <link rel="stylesheet" href="<%=basepath%>/statics/style/css/common.css">
    <script src="<%=basepath%>/statics/style/js/jquery.min.js"></script>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <script>
        //获取地址栏中的键值对
        function getUrlPara(paraName){
            var sUrl = location.href;
            var sReg = "(?:\\?|&){1}"+paraName+"=([^&]*)"
            var re=new RegExp(sReg,"gi");
            re.exec(sUrl);
            return RegExp.$1;
        }
        /*//图片的字符串拼接
        function setimgformat(str){
            var temp=str.split("\\\\");
                console.log(temp);
                var path="../statics/image/"
            var realpath=path+temp[2];
            return realpath;
        }*/

        $(function(){
            var re_data = new Object();
            var c_data=new Object();
            $.ajax({
                url:'../category/Cglist',
                dataType: 'json',
                async:false,
                type:"POST",
                contentType:'application/json;charset=utf-8',
                success: function(data){
                    console.log("ok")
                    var json = data;
                    console.log(json);
                    if (json.code == 1){
                        re_data = json.data;
                        //展示分类名
                        for (var i=0;i<re_data.length;i++){
                            var com="<li><a href=\"../canvas/listdo?cgid="+re_data[i].cgid+"\">"+re_data[i].cgName+"</a></li>";
                            $("#cglist").append(com);
                        }
                    }
                    else {
                        re_data=json.message;
                    }
                },
                error: function (er) {
                    alert(er)
                }
            })

            var cgid=getUrlPara("cgid");
            $.ajax({
                url:'../canvas/Clist',
                dataType: 'json',
                data:{
                    cgid:cgid
                },
                async:false,
                type:"POST",
                success: function(data){
                    var json = data;
                    console.log(json);
                    if (json.code == 1){
                        console.log(json.data);
                        c_data = json.data;
                        //展示油画
                        for (var i=0;i<c_data.length;i++){
                            var dom="<li>\n" +
                                "                        <img class=\"img-li-fix\" src=\"../statics/image/"+c_data[i].img+"\"  alt=\""+c_data[i].name+"\">\n" +
                                "                            <div class=\"info\" >\n" +
                                "                            <h3 class=\"img_title\">"+c_data[i].name+"</h3>\n" +
                                "                            <p >"+c_data[i].description+"</p>\n" +
                                "                            <div class=\"btn\">\n" +
                                "                            <a href=\"../canvas/detail?cid="+c_data[i].cid+"\" class=\"edit\">详情</a>\n" +
                                "                            </div>\n" +
                                "                            </div>\n" +
                                "                            </li>"
                            $("#canvasInfo").append(dom);
                        }
                    }
                    else {
                        c_data=json.message;
                    }
                },
                error: function (er) {
                    alert(er)
                }
            })
        })
    </script>
</head>
<body>
<div class="header">
    <div class="logo f1">
        <img src="<%=basepath%>/statics/image/logo.png">
    </div>
    <div class="auth fr" >
           <%--script中设置分类显示--%>
               <div id="fatie">
                   <% if (null == request.getSession().getAttribute("user")) {%>
                   <ul id="cglist">
                   <li><a href="../user/login">登录</a></li>
                   <li><a href="">注册</a></li>
                   <li><a href="../sall/salls">竞拍</a></li>
                   </ul>
                   <%} else { %>
                   <ul id="cglist">
                       <li>欢迎<%=user.getUname()%></li>
                       <li><a href="../sall/salls">竞拍</a></li>
                   </ul>
                   <% } %>
               </div>
    </div>
</div>
<div class="content">
    <div class="banner">
        <img class="banner-img" src="<%=basepath%>/statics/image/welcome.png" width="732px" height="372" alt="图片描述">
    </div>

    <div class="img-content">
        <ul id="canvasInfo">
          <%--  <li>
                <img class="img-li-fix" src="../statics/image/wumingnvlang.jpg" alt="无名女郎">
                <div class="info" >
                    <h3 class="img_title">无名女郎</h3>
                    <p ></p>
                    <div class="btn">
                        <a href="" class="edit">详情</a>
                    </div>
                </div>
            </li>--%>

        </ul>
    </div>
    <%--<div class="page-nav">
        <ul>
            <li><a href="#">首页</a></li>
            <li><a href="#">上一页</a></li>
            <li><span class="first-page">1</span></li>
            <li><a href="#">2</a></li>
            <li><a href="#">3</a></li>
            <li><a href="#">4</a></li>
            <li><a href="#">5</a></li>
            <li>...</li>
            <li><a href="#">98</a></li>
            <li><a href="#">99</a></li>
            <li><a href="#">下一页</a></li>
            <li><a href="#">尾页</a></li>
        </ul>
    </div>--%>
</div>

<div class="footer">
    <p><span>M-GALLARY</span>©2017 POWERED BY IMOOC.INC</p>
</div>
</body>
</html>
